//
//  QMAModelUtils.h
//  MiniAppSDK
//
//  Created by lkbfeng on 2020/4/3.
//

#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#import <Photos/Photos.h>
#import "QMAEntryModel.h"
#import <WebKit/WebKit.h>

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSInteger, MAUIDelegateShareViewType) {
    MAUIDelegateShareViewTypeNone,
    MAUIDelegateShareViewTypeDebug,             // Debug
    MAUIDelegateShareViewTypevConsoleLog,       // 导出vConsole log
    MAUIDelegateShareViewTypePerformanceClose,  // 关闭性能窗口
    MAUIDelegateShareViewTypePerformanceOpen,   // 打开性能窗口
    MAUIDelegateShareViewTypevConsoleClose,     // 关闭调试
    MAUIDelegateShareViewTypevConsoleOpen,      // 打开调试
    MAUIDelegateShareViewTypeComplaint,         // 举报、投诉与反馈
    MAUIDelegateShareViewTypeSetting,           // 打开设置页
    MAUIDelegateShareViewTypeAbout,             // 关于
    MAUIDelegateShareViewTypeGroupAppSelect,    // 打开群选择面板，添加到群应用
    MAUIDelegateShareViewTypeGroupAppAdd,       // 群场景打开，添加到本群群应用
    MAUIDelegateShareViewTypeFavorites,         // 添加到收藏
    MAUIDelegateShareViewTypeHomePage,          // 回到首页
    MAUIDelegateShareViewTypeShortcut,          // 桌面快捷方式
    MAUIDelegateShareViewTypeCancelTop,         // 从我的移除
    MAUIDelegateShareViewTypeTop,               // 添加到我的
    MAUIDelegateShareViewTypeColorSignCancel,   // 取消彩签
    MAUIDelegateShareViewTypeColorSignAdd,      // 添加彩签
    
    // 分享
    MAUIDelegateShareViewTypeFastShare,         // 最近联系人快速分享
    MAUIDelegateShareViewTypeCustomizedShare,   // 宿主App自定义
    MAUIDelegateShareViewTypeWechatMoment,      // 微信朋友圈
    MAUIDelegateShareViewTypeWechatFriend,      // 微信
    MAUIDelegateShareViewTypeQZone,             // QQ空间
    MAUIDelegateShareViewTypeGuild,             // QQ频道
    MAUIDelegateShareViewTypeFriend,            // QQ好友

    // 录屏
    MAUIDelegateShareViewTypeScreenRecorderStart,   // 开始录屏
    MAUIDelegateShareViewTypeScreenRecorderStop,    // 停止录屏

    MAUIDelegateShareViewTypeEnableBoxFloat, //开启游戏 我的盒子
};

// 分享目标
typedef NS_ENUM(NSUInteger, MAShareTarget) {
    MAShareTargetQQ = 0,              // 分享到QQ
    MAShareTargetQzone,               // 分享到Qzone
    MAShareTargetQQFastForward,       // 分享到QQ，快速分享到当前聊天窗口
    MAShareTargetWXFriends,           // 微信好友
    MAShareTargetWXMoment,            // 微信朋友圈
    MAShareTargetChatFastShare,       // 最近联系人快速分享，从分享面板点击触发
    MAShareTargetFastShareTable,      // 快捷分享好友列表
    MAShareTargetOpenIdShare,         // openId分享，来源小游戏的开放数据域点后后分享
    MAShareTargetGuild,
};

typedef NS_ENUM(NSInteger, QMAToastIconType) {
    QMAToastIconTypeNone,
    QMAToastIconTypeSuccess,
    QMAToastIconTypeLoading,
    QMAToastIconTypeWarn,
};

@interface QMAToastInfo : NSObject

@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy, nullable) NSString *image;
@property (nonatomic, assign) QMAToastIconType iconType;
@property (nonatomic, assign) CGFloat duration; // 毫秒单位
@property (nonatomic, assign) BOOL mask; // 是否显示透明蒙层，防止触摸穿透

- (instancetype)initWithTitle:(NSString *)title icon:(QMAToastIconType)icon duration:(CGFloat)duration;

@end

@interface QMALoadingInfo : NSObject

@property (nonatomic, copy, nullable) NSString *title;
@property (nonatomic, assign) BOOL mask; // 是否显示透明蒙层，防止触摸穿透
@property (nonatomic, assign) BOOL custom; // 是否走自定义的loading
@property (nonatomic, assign) BOOL inWebContainer; // 是否走容器化
@property (nonatomic, assign) NSInteger webviewID; // 容器化webviewId

@property (nonatomic, strong, nullable) UIView *parentView; // 在parentView居中展示，为空的话loading会展示在主window上

@end

@interface QMASheetActionParams : NSObject

@property (nonatomic, strong) QMAEntryModel *chatModel; // 目前只在QQ快速分享使用
@property (nonatomic, assign) BOOL isTTScreenRecorderGuideViewShowing; // 录屏新手引导是否正在展示

@end

@interface QMASheetItemInfo : NSObject

@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) void (^action)(QMASheetActionParams * _Nullable params);
@property (nonatomic, assign) MAUIDelegateShareViewType type;
@property (nonatomic, strong) UIColor *titleColor;
@property (nonatomic, assign) BOOL isHidden;

- (instancetype)initWithTitle:(NSString *)title action:(void (^  _Nullable)(QMASheetActionParams * _Nullable params))action;
- (instancetype)initWithTitle:(NSString *)title
                         type:(MAUIDelegateShareViewType)type
                       action:(void (^  _Nullable)(QMASheetActionParams * _Nullable params))action;

@end

typedef NS_ENUM(NSInteger, QMAGroupAppAddStatus) {
    QMAGroupAppAddStatusFail,           // 请求失败
    QMAGroupAppAddStatusSuccess,        // 添加成功
    QMAGroupAppAddStatusRepeat,         // 已存在，重复添加
};

typedef NS_ENUM(NSInteger, QMAGroupAppCheckStatus) {
    QMAGroupAppCheckStatusFail,         // 请求失败
    QMAGroupAppCheckStatusExisted,      // 存在
    QMAGroupAppCheckStatusNotExisted,   // 不存在
};

@interface QMAGroupAppOperateModel : NSObject

@property (nonatomic, assign) QMAGroupAppAddStatus addStatus; // 添加请求使用
@property (nonatomic, assign) QMAGroupAppCheckStatus checkStatus; // 查询请求使用
@property (nonatomic, strong) NSNumber *responseCode; // 记录请求响应码
@property (nonatomic, copy) NSString *failTips; // 当addStatus/checkStatus为"请求失败"时记录错误信息

- (instancetype)initWithFailTips:(NSString *)tips addStatus:(QMAGroupAppAddStatus)addStatus;
- (instancetype)initWithFailTips:(NSString *)tips checkStatus:(QMAGroupAppCheckStatus)checkStatus;

@end

#pragma mark - chooseImage chooseVideo

typedef NS_ENUM(NSInteger, QMAMediaChooseType) {
    QMAMediaChooseTypeImage,
    QMAMediaChooseTypeVideo,
};

typedef NS_OPTIONS(NSUInteger, QMAMediaChooseTypeMask) {
    QMAMediaChooseTypeMaskImage = 1 << QMAMediaChooseTypeImage,
    QMAMediaChooseTypeMaskVideo = 1 << QMAMediaChooseTypeVideo,
    QMAMediaChooseTypeMaskAll = QMAMediaChooseTypeMaskImage | QMAMediaChooseTypeMaskVideo,
};

typedef NS_ENUM(NSInteger, QMAMediaCompressType) {
    QMAMediaCompressTypeOriginal,
    QMAMediaCompressTypeCompress,
};

typedef NS_OPTIONS(NSUInteger, QMAMediaCompressTypeMask) {
    QMAMediaCompressTypeMaskOriginal = 1 << QMAMediaCompressTypeOriginal,
    QMAMediaCompressTypeMaskCompress = 1 << QMAMediaCompressTypeCompress,
};

@interface QMAMediaChooseVideoConfig : NSObject

@property (nonatomic, assign) NSInteger maxVideoDuration; // 针对视频
@property (nonatomic, assign) BOOL isFront;
@property (nonatomic, copy) void(^processCompletionBlock)(void); // 视频处理完毕后会执行的block

@end

@interface QMAMediaChooseConfigModel : NSObject

@property (nonatomic, assign) QMAMediaChooseTypeMask chooseTypeMask;
@property (nonatomic, assign) QMAMediaCompressTypeMask compressTypeMask;
@property (nonatomic, assign) NSInteger maxCount;
@property (nonatomic, strong) QMAMediaChooseVideoConfig *videoConfig; // 视频参数

@end

@interface QMAPickerImageModel : NSObject

@property (nonatomic, assign) BOOL isOriginal; // 用户是否勾选了原图按钮
@property (nonatomic, strong) PHAsset *asset;
@property (nonatomic, strong) UIImage *image; // 如果有会优先使用image

@end

@interface QMAPickerVideoModel : NSObject

@property (nonatomic, strong) PHAsset *asset;

@end

@interface QMACameraImageModel : NSObject

@property (nonatomic, strong) UIImage *image;

@end

@interface QMACameraVideoModel : NSObject

@property (nonatomic, strong) AVURLAsset *asset;

@end

@interface QMAWebViewVCModel : NSObject

// 跳转的 url
@property (nonatomic, copy) NSString *url;
// HTTP Request Referer 
@property (nonatomic, copy) NSString *referrer;
// 跳转检查
@property (nonatomic, copy) BOOL(^decidePolicy)(NSURL *url, void (^decisionHandler)(WKNavigationActionPolicy));

@property (nonatomic, assign) BOOL forcePortrait; // 是否强制竖屏展示

@end

NS_ASSUME_NONNULL_END
